﻿using System;

namespace FunctionalCLR.Core {
    public class RadianToDegree : FuncNode {
        public RadianToDegree()
            : base() {
            base.Value = "radianToDegree";
        }

        public override FuncNode GetReversedFunction(int index) {
            throw new NoOppositeOperatorException(string.Format(
                "Function {0} cannot be transformed", this.Value));
        }

        public override object Evaluate() {
            if (Children.Count < 1) {
                throw new ArgumentException("usage: radianToDegree(radian);");
            }

            double result = Convert.ToDouble(Children[0].Evaluate());

            return result * 180 / Math.PI;
        }
    }
}
